package com.baofu.paycore.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 资金单类型
 * <p>
 *     1、支付资金单
 *     2、充值资金单
 *     3、转账冻结资金单
 *     4、解冻转账资金单
 *     5、提现冻结资金单
 *     6、解冻提现资金单
 *     7、充值转账资金单（对应银行卡支付这种，先充值再转账流程中的转账资金单）
 *     8、退款资金单
 *     9、手续费资金单
 * </p>
 * User: xin deng  Date: 16/6/18 ProjectName: paycore Version: 1.0
 */
@Slf4j
@Getter
@AllArgsConstructor
public enum FundTypeEnum {

    PAY("PAY", "支付资金单"),

    RECHARGE("RECHARGE", "充值资金单"),

    TRANSFER("TRANSFER", "转账资金单"),

    REFUND_FREEZE("REFUND_FREEZE", "退款冻结资金单"),

    TRANSFER_FREEZE("TRANSFER_FREEZE", "转账冻结资金单"),

    WITHDRAW_FREEZE("WITHDRAW_FREEZE", "提现冻结资金单"),

    UNFREEZE_WITHDRAW("UNFREEZE_WITHDRAW", "解冻提现资金单"),

    EX_UNFREEZE_WITHDRAW("EX_UNFREEZE_WITHDRAW", "异常解冻提现资金单"),

    UNFREEZE_TRANSFER("UNFREEZE_TRANSFER", "解冻转账资金单"),

    RECHARGE_TRANSFER("RECHARGE_TRANSFER","充值转账资金单"),

    PRE_AUTH("PRE_AUTH", "预授权资金单"),

    PRE_AUTH_CANCEL("PRE_AUTH_CANCEL", "预授权撤销资金单"),

    PRE_AUTH_CONFIRM_FEE("PRE_AUTH_CONFIRM_FEE", "预授权完成手续费单"),

    PRE_AUTH_CONFIRM("PRE_AUTH_CONFIRM", "预授权完成资金单"),

    TRANSFER_REFUND("TRANSFER_REFUND","转账退款资金单"),

    PAY_RECHARGE_REFUND("PAY_RECHARGE_REFUND","支付流程账务充值退款资金单"),

    PAY_BANK_REFUND("PAY_BANK_REFUND", "支付流程银行卡退款资金单"),

    FEE("FEE", "手续费资金单");

    /**
     * 编码
     */
    private String code;

    /**
     * 描述
     */
    private String desc;

    /**
     * 通过枚举编码获得枚举
     *
     * @param code    枚举编码
     * @return        返回编码对应的枚举类型
     */
    public static FundTypeEnum explain(String code) {
        for (FundTypeEnum fundTypeEnum : values()) {
            if (fundTypeEnum.getCode().equals(code)) {
                return fundTypeEnum;
            }
        }
        return null;
    }
}
